package net.oschina.app.util;

import android.graphics.Color;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import net.oschina.app.R;
import net.oschina.app.base.BaseActivity;

/**
 * Created by Shinelon on 2017/1/14.
 */

public class ToolBarUtil {


    private static Toolbar mToolbar;

    private ToolBarUtil() {}

    public static void setToolBar(final BaseActivity activity,String title) {
        mToolbar = (Toolbar) activity.findViewById(R.id.tl);
        TextView tv = (TextView) activity.findViewById(R.id.tv_toolbar_title);
        Button btn = (Button) activity.findViewById(R.id.btn_back);
        tv.setText(title);
        mToolbar.setBackgroundColor(Color.parseColor("#3AAC54"));
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                activity.finish();
            }
        });
    }

    public static void setRefreshView(boolean display) {
        if (display){
            mToolbar.inflateMenu(R.menu.refresh_menu);
        }else {
            mToolbar.inflateMenu(R.menu.blank_view);
        }

    }
}
